package com.example.gientechthree.producer;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

@EnableBinding(Source.class)
public class MessageProducerImpl implements MessageProducer{
    @Resource
    private MessageChannel output;//消息发送管道

    @Override
    public boolean send() {
        String uuid = UUID.randomUUID().toString();
        boolean send = output.send(MessageBuilder.withPayload(uuid).build());
        System.out.println(uuid);
        return send;
    }
}
